package main

import (
	"fmt"
	"sort"
)

func main() {
	ages := map[string]int{
		"alice":   31,
		"charlie": 34,
	}

	ages["alice"] = 32
	fmt.Println(ages["alice"]) // "32"

	fmt.Println(ages)

	delete(ages, "alice") // remove element ages["alice"]

	ages["bob"] = ages["bob"] + 1 // happy birthday!

	for name, age := range ages {
		fmt.Printf("%s\t%d\n", name, age)
	}

	var names []string
	for name := range ages {
		names = append(names, name)
	}
	sort.Strings(names)
	for _, name := range names {
		fmt.Printf("%s\t%d\n", name, ages[name])
	}

	// names := make([]string, 0, len(ages))

	if _, ok := ages["bob"]; !ok {
		fmt.Println(ok)
	}
}

var graph = make(map[string]map[string]bool)

func addEdge(from, to string) {
	edges := graph[from]
	if edges == nil {
		edges = make(map[string]bool)
		graph[from] = edges
	}
	edges[to] = true
}

func hasEdge(from, to string) bool {
	return graph[from][to]
}
